/**
 * DLA/Oscilloscope Project Software
 * 
 * By Kevin Cuzner <kevincuzner@yahoo.com>
 * 
 * This file is part of the DLA/Oscilloscope Project Software.
 *
 * The DLA/Oscilloscope Project Software is free software: you can 
 * redistribute it and/or modify it under the terms of the GNU Lesser
 * General Public License as published by the Free Software Foundation,
 * either version 3 of the License, or (at your option) any later version.
 *
 * The DLA/Oscilloscope Project Software is distributed in the hope
 * that it will be useful, but WITHOUT ANY WARRANTY; without even the
 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with The DLA/Oscilloscope Project Software.
 * If not, see <http://www.gnu.org/licenses/>.
 */

using System;
using System.IO;
using System.Collections.Generic;

namespace DLAOscilloscopegtk
{
	/// <summary>
	/// A SampleSource based on a file. This sample source cannot have many
	/// properties changed since it is reading from a static file.
	/// </summary>
	/// <exception cref='NotImplementedException'>
	/// Is thrown when a requested operation is not implemented for a given type.
	/// </exception>
	public class FileSampleSource : ISampleSource
	{
		protected string name; //the name of the file that has been opened for this class
		protected int channels; //the number of channels the file has specified
		protected int channelwidth; //the width of each channel in the file
		protected long frequency; //the frequency of the samples stored in the file
		protected SampleType type; //the sample type of the samples in the file
		//protected File inputFile; //the file we are reading input from
		protected Queue<SampleWindow> windowQueue; //a queue containing the samplewindows from the input file
		
		/// <summary>
		/// Initializes a new instance of the <see cref="DLAOscilloscopegtk.FileSampleSource"/> class from a file.
		/// </summary>
		/// <param name='fileName'>
		/// File name to initialize from.
		/// </param>
		public FileSampleSource (string fileName)
		{
			name = fileName;
			channels = 0;
			channelwidth = 0;
			frequency = 0;
			type = SampleType.ANALOG;
		}
		
		public SampleWindow ReadSampleWindow ()
		{
			throw new NotImplementedException ();
		}
		
		public bool SampleWindowAvailable ()
		{
			throw new NotImplementedException ();
		}
		
		/// <summary>
		/// Requests a new sample speed. In a FileSampleSource, this has no effect since the
		/// sampling speed cannot be changed.
		/// </summary>
		/// <returns>
		/// The set sample speed.
		/// </returns>
		/// <param name='s'>
		/// Requested speed
		/// </param>
		public long RequestSampleSpeed (long s)
		{
			//this particular type of samplesource cannot have the speed changed
			return frequency;
		}
		
		/// <summary>
		/// Requests the type of the sample to get from the sample source. In a FileSampleSource,
		/// this has no effect since the sample type cannot be changed
		/// </summary>
		/// <returns>
		/// The set sample type.
		/// </returns>
		/// <param name='t'>
		/// Requested sample type
		/// </param>
		public bool RequestSampleType (SampleType t)
		{
			//this particular type of samplesource cannot have the sample type changed
			return false;
		}
		
		public void SetRaw (bool raw)
		{
			throw new NotImplementedException ();
		}
		
		public ChannelMapping.ChannelMappingContainer Channels {
			get {
				return null;
			}
		}
		
		public int ChannelWidth {
			get {
				return channelwidth;
			}
		}
		
		public long SampleSpeed {
			get {
				return frequency;
			}
		}
		
		public SampleType SampleType {
			get {
				return type;
			}
		}
		
		public string Name {
			get {
				return "File: " + name;
			}
		}
	}
}

